package com.duvee.uiautomator.interfaceImp;

import java.io.IOException;

import com.duvee.uiautomator.bean.TestCaseBean;
import com.duvee.uiautomator.interfaces.AuxiliaryInterface;

/**
 * 实现辅助功能，截图、写用例等
 * 
 * @author duvee
 * 
 */
public class AuxiliaryInterfacefaceImp implements AuxiliaryInterface {
	/**
	 * 后期自动推送到远端的时候使用
	 */
	@Override
	public boolean screenShot() {

		return false;
	}

	@Override
	public boolean writeResult(String fileName, TestCaseBean testCase) {

		return false;
	}

	@Override
	public boolean exportLogCat(String name) {
		// 启动APP
		try {
			System.out.println("======/storage/sdcard0/UIAutomatorInfo/" + name
					+ "_log.txt");
			Runtime.getRuntime().exec("adb shell logcat -c");
			Runtime.getRuntime()
					.exec("adb shell logcat -v time -f /storage/sdcard0/UIAutomatorInfo/"
							+ name + "_log.txt *:W &");
			// adb shell logcat -v time -f /storage/sdcard0/tmp/a.txt *:W
			return true;
		} catch (IOException e) {
			System.out.println("===" + e.getMessage());
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public boolean stopAdb() {
		// 启动APP
		try {

			Runtime.getRuntime().exec("exit");
			return true;
		} catch (IOException e) {
			e.printStackTrace();
			return false;
		}
	}
}
